package dyyx;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.startup.Tomcat;

public class Main2 {

	public static void main(String[] args) throws Exception {
		Tomcat tomcat = new Tomcat();
        
		
		Connector connector = new Connector("org.apache.coyote.http11.Http11Nio2Protocol");
		connector.setPort(8080);
		// org.apache.coyote.http11.Http11NioProtocol
		// org.apache.coyote.http11.Http11Nio2Protocol
		// String protocolHandlerClassName = "org.apache.coyote.http11.Http11Nio2Protocol";
		// connector.setProtocolHandlerClassName(protocolHandlerClassName);
		tomcat.setConnector(connector);
		tomcat.getService().addConnector(connector);
		
        String contextPath = "";

        StandardContext context = new StandardContext();
        context.setPath(contextPath);
        context.addLifecycleListener(new Tomcat.FixContextListener());
        tomcat.getHost().addChild(context);

        tomcat.addServlet(contextPath, "hello", new HelloServlet());
        context.addServletMapping("/hello", "hello");

        tomcat.start();

        tomcat.getServer().await();
		
	}
}
